import java.awt.Point;
import java.awt.geom.Point2D;

public class Bullet {
	
	int framerate;
	double dT;
	
	double angle = 0;
	double turnPerSec = 40 * 180 / Math.PI;
	double turnPerFrame;
	
	
	final double bulletSpeed = 600; //pixels per second
	final double mass = 1.6; //mass relative to player mass (i.e. mass .3 means playermass * 3/10)
	
	boolean toDelete = false;
	Point2D.Double pos,vel;
	
	public Bullet( Point2D.Double pos, Point2D.Double unitFiringVector, int framerate){
		this.pos = pos;	
		vel = new Point2D.Double( bulletSpeed * unitFiringVector.x / framerate, bulletSpeed * unitFiringVector.y/framerate);
		this.framerate = framerate;
		this.dT = 1/(double)framerate;
		this.turnPerFrame = turnPerSec/(double)framerate;
	}
	
	public void update(Player player, double fx, double fy){
		
		angle = (angle+turnPerFrame)%(Math.PI * 2);
			
		vel.x += fx / mass * dT;
		vel.y += fy / mass * dT;		
		
		pos.x = GarbooMain.m2px(GarbooMain.px2m(pos.x) + vel.x * dT);
		pos.y = GarbooMain.m2px(GarbooMain.px2m(pos.y) + vel.y * dT);
		
		
		if( !(pos.x < 1280) || !(pos.y < 800) || !(pos.x > 0) || !(pos.y > 0 )){
			toDelete = true;
		}
		
	}
	
	public Point getPointLocation(){
		return new Point( (int)(pos.x), (int)(pos.y)); //dont need to round, its really close anyways
	}
	
	
	
}
